//
//  SSSMyMemberCell.m
//  SSSMerchant
//
//  Created by Darker on 2017/3/25.
//  Copyright © 2017年 xnxin. All rights reserved.
//

#import "SSSMyMemberCell.h"

@interface SSSMyMemberCell()

{
    
    
}

@end

@implementation SSSMyMemberCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
       // [self layoutSubviews];
        [self addSubViews];
    }
    return self;
}

- (void)addSubViews{
    
    self.accessoryView.frame = CGRectMake(0, 0, 0, 0);
    
    UIView *cententerView = [UIView new];
    cententerView.frame = self.frame;
    [self addSubview:cententerView];
    cententerView.sd_layout
    .rightEqualToView(self)
    .leftEqualToView(self)
    .topEqualToView(self)
    .bottomEqualToView(self);
    
    CGFloat width = KSCREEN_Width/3;
    //cententerView.backgroundColor = [UIColor redColor];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    _nameLabel = [UILabel new];
    _nameLabel.textAlignment = NSTextAlignmentCenter;
    _nameLabel.font = [SSSFont systemFontOfSize:12];
    _nameLabel.textColor = [UIColor colorWithHex:@"6D6D6D"];
    [cententerView addSubview:_nameLabel];
    _nameLabel.sd_layout
    .leftEqualToView(cententerView)
    .topEqualToView(cententerView)
    .bottomEqualToView(cententerView)
    .widthIs(width);
    
    _phoneLabel = [UILabel new];
    _phoneLabel.textAlignment = NSTextAlignmentCenter;
    _phoneLabel.font = [SSSFont systemFontOfSize:12];
    _phoneLabel.textColor = [UIColor colorWithHex:@"6D6D6D"];
    [cententerView addSubview:_phoneLabel];
    _phoneLabel.sd_layout
    .leftSpaceToView(_nameLabel,0)
    .topEqualToView(cententerView)
    .bottomEqualToView(cententerView)
    .widthIs(width);
    
    _timeLabel = [UILabel new];
    //_timeLabel.text = @"2097-47-16";
    _timeLabel.textAlignment = NSTextAlignmentCenter;
    _timeLabel.font = [SSSFont systemFontOfSize:12];
    _timeLabel.textColor = [UIColor colorWithHex:@"6D6D6D"];
    [cententerView addSubview:_timeLabel];
    _timeLabel.sd_layout
    .leftSpaceToView(_phoneLabel,0)
    .topEqualToView(cententerView)
    .bottomEqualToView(cententerView)
    .widthIs(width);
    
    UIView *lineView = [UIView new];
    lineView.backgroundColor = [UIColor colorWithHex:@"E5E5E8"];
    [cententerView addSubview:lineView];
    lineView.sd_layout
    .leftEqualToView(cententerView)
    .rightEqualToView(cententerView)
    .bottomEqualToView(cententerView)
    .heightIs(0.5);
}

- (void)setMyMemberModel:(SSSMyMemberModel *)myMemberModel{
    
    _myMemberModel = myMemberModel;
    self.nameLabel.text = myMemberModel.name;
    self.phoneLabel.text = myMemberModel.phone;
    if (myMemberModel.joinTime.length == 0) {
        
        self.timeLabel.text = @"";
        
    }else{
        
        NSString *subStr = [myMemberModel.joinTime substringWithRange:NSMakeRange(0,myMemberModel.joinTime.length - 3)];
        self.timeLabel.text = [NSString timeDateStrFromTimeStamp:subStr];
    }
    //[self setNeedsLayout];
    [self layoutIfNeeded];
}
- (void)layoutIfNeeded{
    
    [super layoutIfNeeded];
    
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
